package com.hncu.test;

import com.hncu.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

//特别注意！！！！！如果nextInt()与nextline()配套使用，nextline()自动是空字符串
public class Demo3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //创建集合
        ArrayList<Student> arrayList = new ArrayList<>();
        //三个学生对象
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入名字：");
            String name = in.next();
            System.out.println("请输入年龄：");
            int age = in.nextInt();
            Student stu = new Student(name, age);
            arrayList.add(stu);
        }
        //遍历集合
        for (int i = 0; i < arrayList.size(); i++) {
            Student student = arrayList.get(i);
            System.out.println(student.getAge() + "..." + student.getName());
        }
    }
}
